package com.bjsxt.back.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bjsxt.common.controller.BaseController;
import com.bjsxt.common.util.ConstantFinal;
import com.bjsxt.common.util.DateFormatUtil;
import com.bjsxt.common.util.PageInfoUtil;
import com.bjsxt.system.pojo.Regin;
import com.bjsxt.system.service.ISystemService;

@Controller
@RequestMapping("/back/system/")
public class SystemBackController extends BaseController
{
	@Resource
	private ISystemService systemService;
	//打开国家区域列表
	@RequestMapping("regionList.htm")
	public String regionList(HttpServletRequest req)
	{
		PageInfoUtil pageInfo = this.getPageInfoUtil(req);
		
		String keyword = req.getParameter("keyword");
		String status = req.getParameter("status");
		if(keyword==null)
		{
			keyword="";
		}
		keyword=keyword.trim();
		if(status==null)
		{
			status="";
		}
		status=status.trim();
		String st = req.getParameter("st");
		String ed = req.getParameter("ed");
		
		Date stDate=null;
		Date edDate=null;
		if(st!=null && ed!=null)
		{
			try
			{
				stDate = DateFormatUtil.parseIntoDateTime(st);
				edDate = DateFormatUtil.parseIntoDateTime(ed);
			} catch (Exception e)
			{
			}
		}
		
		String parentId = req.getParameter("parentId");
		Map<String,Object> condMap=new HashMap<String,Object>();
		condMap.put("keyword", keyword);
		condMap.put("status", status);
		condMap.put("stDate", stDate);
		condMap.put("edDate", edDate);
		condMap.put("parentId", parentId);
		
		List<Regin> regionList = this.systemService.findListRegin(pageInfo, condMap);
		req.setAttribute("regionList", regionList);
		req.setAttribute("keyword", keyword);
		req.setAttribute("status", status);
		req.setAttribute("st", st);		
		req.setAttribute("ed", ed);
		req.setAttribute("pageInfo", pageInfo);
		req.setAttribute("parentId", parentId);
		
		return "/back/system/regionList";
	}
}
